package solvoku;

import java.util.logging.Level;
import java.util.logging.Logger;
import solvoku.model.game.Case;
import solvoku.model.game.CoupAJouer;
import solvoku.model.game.Grille;
import solvoku.model.solver.Solver;
import solvoku.model.solver.exceptions.ValeursGrilleException;

/**
 *
 * @author Steve Cancès <steve.cances@gmail.com>
 */
public class Solvoku {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Integer[][] values = {
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {}
        };

        Integer[][] valuesEasy = {
            {0, 5, 0, 0, 2, 0, 9, 8, 0},
            {3, 4, 0, 9, 0, 1, 0, 0, 0},
            {0, 2, 0, 3, 0, 7, 0, 4, 5},
            {9, 0, 0, 0, 0, 5, 7, 0, 0},
            {2, 6, 0, 7, 0, 0, 4, 0, 0},
            {0, 8, 0, 0, 0, 0, 0, 2, 1},
            {5, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 6, 0, 0, 0, 2, 1, 0},
            {0, 0, 0, 8, 0, 6, 0, 3, 0}
        };

        Integer[][] valuesExpert = {
            {0, 0, 7, 2, 6, 0, 0, 0, 9},
            {0, 6, 0, 0, 1, 9, 0, 0, 0},
            {0, 4, 0, 7, 0, 0, 0, 0, 0},
            {0, 0, 1, 0, 0, 0, 0, 0, 4},
            {0, 0, 0, 0, 0, 0, 3, 0, 7},
            {0, 2, 0, 0, 0, 0, 8, 0, 0},
            {0, 9, 0, 0, 0, 2, 0, 8, 1},
            {0, 0, 0, 0, 0, 0, 0, 0, 3},
            {6, 8, 0, 4, 3, 0, 0, 0, 0}
        };

        Integer[][] valuesExpert2 = {
            {0, 0, 0, 6, 8, 7, 0, 0, 0},
            {0, 6, 1, 0, 0, 2, 0, 3, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 9, 0, 1, 0, 5, 0},
            {0, 0, 0, 0, 3, 0, 0, 0, 0},
            {0, 5, 0, 0, 7, 0, 0, 1, 2},
            {9, 0, 2, 0, 0, 3, 0, 8, 0},
            {3, 0, 0, 7, 5, 0, 2, 0, 0},
            {0, 8, 0, 0, 2, 0, 1, 0, 0}
        };

        Integer[][] valuesExpert3 = {
            {0, 0, 3, 4, 0, 8, 0, 6, 0},
            {2, 9, 0, 7, 0, 0, 3, 0, 0},
            {0, 0, 5, 0, 0, 0, 0, 0, 7},
            {3, 0, 0, 0, 0, 2, 4, 0, 0},
            {6, 0, 7, 0, 0, 0, 0, 0, 0},
            {0, 2, 0, 0, 7, 0, 0, 0, 0},
            {0, 7, 0, 3, 0, 0, 9, 5, 0},
            {5, 0, 6, 0, 0, 0, 2, 3, 0},
            {9, 0, 0, 0, 0, 0, 0, 0, 6}
        };

        try {
            Solver solver = new Solver(valuesExpert3);
            if (solver.isSolvable()) {
                System.out.println("Grille résolue : \n");
                System.out.println(solver.getGrilleResolue());
                
                System.out.println("Grille de base : \n");
                System.out.println(solver.getGrille());
                
                /*
                for(CoupAJouer coupAJouer : solver.getCoupsAJouer()){
                    coupAJouer.jouerCoup();
                    System.out.println(solver.getGrille());
                }
                */
                
                while(solver.jouerProchainCoupAJouer()){
                    System.out.println(solver.getGrille());
                }
            } else {
                System.out.println("La grille n'est pas solvable");
            }

        } catch (ValeursGrilleException ex) {
            Logger.getLogger(Solvoku.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
